import React, { Component } from 'react';
import Card from './components/Card';
import axios from 'axios'
// 商品列表页面
class GoodsList extends Component {
    constructor(props) {
        super(props)
        this.state = {
          goods:[],//商品数据
        }
      }

  componentDidMount(){
    // axios请求
    axios.get("http://api.kudesoft.cn/tdk/goods").then(res=>{
      // console.log(res.data.data.data.list);
      // 更新state的状态
      this.setState({
        goods:res.data.data.data.list
      })
    }).catch(err=>{
      console.log(err)
    })
  }

  render() {
    return (
      <div className="GoodsList">
        {/* 将数据传递给子组件展示 */}
        <Card list={this.state.goods} history={this.props.history} />
      </div>
    );
  }

}

export default GoodsList;
